.chat-container {
  width: 100%;
  max-width: 920px;
  /* 固定高度：自适应视口，减去顶部空间(导航60px + el-main padding 20px + 面包屑38px) + 底部留白(面包屑占位38px + el-main padding 20px) */
  height: calc(100vh - 176px);
  margin: 0 auto 38px auto;  /* 底部补偿面包屑高度(22px) + margin(16px)，实现上下对称 */
  border: none;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(to bottom right, #f9fafb, #ffffff);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #eef0f3;
}
.chat-title {
  font-size: 16px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;

  :deep(.el-button) {
    padding: 6px 12px;
    font-size: 14px;
    color: #606266;
    transition: all 0.2s;

    .el-icon {
      margin-right: 4px;
      font-size: 16px;
      color: #409eff;
    }

    &:hover {
      background-color: rgba(64, 158, 255, 0.1);
      color: #409eff;

      .el-icon {
        color: #409eff;
      }
    }
  }
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #ffffff;
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

.chat-message { margin-bottom: 14px; display: flex; }
.chat-message.user { justify-content: flex-end; }
.chat-message.ai { justify-content: flex-start; }

.message-inner { display: flex; gap: 10px; align-items: flex-start; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.avatar-input { width: 32px; height: 32px; margin-right: 10px; }

.message-content {
  max-width: 70%;
  padding: 10px 14px;
  line-height: 1.75;
  word-wrap: break-word;
  animation: fadeIn 0.25s ease;
}
.chat-message.user .message-content {
  background-color: #d1e7dd; color: #0f5132; border-radius: 8px 8px 0 8px; box-shadow: 0 2px 6px rgba(15,81,50,0.1);
}
.chat-message.ai .message-content {
  background-color: #e9ecef; color: #212529; border-radius: 8px 8px 8px 0; box-shadow: 0 2px 6px rgba(33,37,41,0.05);
}

.role { font-weight: 600; margin-right: 6px; color: #4b5563; }

.chat-input-area {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.chat-input {
  flex: 1;
  height: 100px;
  resize: none;
  border: 1px solid #dcdfe6;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.6;
  background-color: #ffffff;
  color: #606266;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-sizing: border-box;

  &:focus {
    outline: none;
    border-color: #409eff;
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
  }

  &::placeholder {
    color: #c0c4cc;
  }
}

.send-btn {
  height: 100px;
  padding: 0 28px;
  background-color: #409eff;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.3s;
  box-sizing: border-box;

  &:hover {
    background-color: #66b1ff;
    box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
  }

  &:active {
    box-shadow: none;
  }

  &:disabled {
    background-color: #c0c4cc;
    cursor: not-allowed;
    box-shadow: none;
  }
}

// 欢迎消息
.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #909399;

  h3 {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 500;
    color: #606266;
  }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

// ============ 暗黑模式适配 ============
:global(.dark) {
  .chat-container {
    background: linear-gradient(to bottom right, #1a1a1a, #1e1e1e);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  }

  .chat-header {
    border-bottom-color: #303030;
  }

  .chat-title {
    color: #e5eaf3;
  }

  .header-actions {
    :deep(.el-button) {
      color: #e5eaf3;
      background-color: rgba(255, 255, 255, 0.05);

      .el-icon {
        color: #409eff;
      }

      &:hover {
        color: #409eff;
        background-color: rgba(64, 158, 255, 0.15);

        .el-icon {
          color: #66b1ff;
        }
      }
    }
  }


  .role {
    color: #b3b3b3;
  }

  // 用户消息 - 深色模式下使用系统主题蓝色
  .chat-message.user .message-content {
    background-color: #0d4a7a;
    color: #e5eaf3;
    box-shadow: 0 2px 8px rgba(64, 158, 255, 0.15);
  }

  // AI消息 - 深色模式下使用深灰色
  .chat-message.ai .message-content {
    background-color: #252525;
    color: #e5eaf3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .chat-input-area {
    background-color: #1e1e1e;
    border-top-color: #303030;
  }

  .chat-input {
    background-color: #2a2a2a;
    color: #e5eaf3;
    border-color: #5f5f5f;

    &:focus {
      border-color: #409eff;
      box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.15);
    }

    &::placeholder {
      color: #999;
    }
  }

  .send-btn {
    background-color: #409eff;
    color: #ffffff;

    &:hover {
      background-color: #66b1ff;
      box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
    }

    &:disabled {
      background-color: #3a3a3a;
      color: #666;
    }
  }

  // 欢迎消息
  .welcome-message {
    color: #666;

    h3 {
      color: #b3b3b3;
    }
  }
}

// ============ 深色模式滚动条（全局样式，优先级更高） ============
:global(html.dark) {
  .chat-messages::-webkit-scrollbar-track {
    background: #1e1e1e !important;
    border-radius: 4px;
  }

  .chat-messages::-webkit-scrollbar-thumb {
    background-color: #4f4f4f !important;
    border-radius: 4px;
  }

  .chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: #6f6f6f !important;
  }
}
